package com.highper.common.runner;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @Author ZhangGJ
 * @Date 2022/01/22 15:29
 */
@Slf4j
@Component
public class StartRunner implements ApplicationRunner {

    private final ConfigurableApplicationContext context;

    private final Environment environment;

    public StartRunner(ConfigurableApplicationContext context, Environment environment) {
        this.context = context;
        this.environment = environment;
    }

    @Override
    public void run(ApplicationArguments args) {
        if (context.isActive()) {
            RunnerUtil.applicationStartBanner(context, environment);
        }
    }

}
